package com.chenwei.rabbit.workQueues;

import com.chenwei.rabbit.MQUtils;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;

import java.io.IOException;

/**工作队列（任务模型） 一个生产者一个队列多个消费者
 * @author: chenwei
 * @date: 2021/3/31 15:29
 */
public class Provider {
    public static void main(String[] args) throws IOException {
        Connection connection = MQUtils.getConnection();
        Channel channel = connection.createChannel();

        channel.queueDeclare("study", true, false, false, null);
        //生产十个消息
        for (int i = 0; i < 10; i++) {
            channel.basicPublish("", "study", null, ("work Queues"+i).getBytes());
        }
        MQUtils.close(channel, connection);
    }
}
